/*************************************************************************
	> File Name: Algorithm.h
	> Author: 
	> Mail: 
	> Created Time: 2021年12月22日 星期三 15时25分40秒
 ************************************************************************/

#ifndef _WMARK_DEV__H
#define _WMARK_DEV__H
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <log/log.h>
#include <utils/Thread.h>
#include <unistd.h>
#include <sys/epoll.h>
#include "wmark_dev.h"
#include "Device.h"
#include "ResultBufIntface.h"
#include "ControlMsgIntface.h"

#define MAX_EVENTS 10
#define DEV "/dev/wmark_dev_lookback"

using android::wmark::Device;
using android::Thread;

namespace camera
{
    namespace algorithm
    {

        class WmarkDev : public Device, public Thread
        {
        private:
            static WmarkDev *instance;
            ResultBufIntface *mResultCallBack = NULL;
            ControlMsgIntface *mCtlMsgCallBack = NULL;

        private:
            WmarkDev();
            ~WmarkDev();
            int handlePoll();
            virtual bool threadLoop() override;
            int getUseWBufInfo();
            int getMsgCtl();

        public:
            static WmarkDev *getInstance()
            {
                if (instance == NULL)
                    instance = new WmarkDev();
                return instance;
            }

            int getWmarkBufsInfo(uint32_t &bufNum, uint64_t &bufLen);
            void registerResultCallback(ResultBufIntface *callback) {mResultCallBack = callback;}
            void registerCtlMsgCallback(ControlMsgIntface *callback) {mCtlMsgCallBack = callback;}
            int setFreeWBufInfo(int dmaBufIndex);

            void start();
            void stop();
        };

    } // algorithm
} // camera
#endif